'''
# Coding:utf-8
# Project: iiop
# Author: rtf
# Time: 2021-04-06 13:58:38
# FileName: excel_process.py
# Software: PyCharm
'''


import pandas as pd


def get_data():
    excel_path = '/home/rtf/Project/Jna/iiop/download/用户模板.xlsx'
    df = pd.read_excel(excel_path)
    data = []
    for i in df.index.values:
        row_data = df.iloc[i, [0, 1, 2, 3, 4]].to_dict()
        data.append(row_data)

    user_data = list()
    for i in data:
        i["account"] = i.get("账号")
        i["realname"] = i.get("姓名")
        i["role_code"] = "EMPLOYEE"
        i["enabled"] = 1 if i.get("用户状态") == "启用" else 0
        i["password"] = "Qhdl@1234"
        dept_list = i.get("所属组织").split("|")
        dept_list_len = len(dept_list)
        if dept_list_len > 1:
            dept_name = dept_list[dept_list_len - 1]
            parent_name = dept_list[dept_list_len - 2]
        else:
            dept_name = dept_list[len(dept_list) - 1]
        # print("===========", dept_name, parent_name)
        i["所属组织"] = dept_list
        user_data.append({"account": "ceshi1",
                          "realname": "测试数据1",
                          "role_code": "EMPLOYEE",
                          "dept_code": "SG_QHDL_XXTX_HX_XXYWB",
                          "enabled": 1,
                          "password": "Qhdl@1234"})
    return data


# print(get_data())
